import {
	createOrder
} from '@/request/api.js'
export default {
	methods: {
		getOpenMap(data) {
			// console.log(data,1111)
			uni.openLocation({
				latitude: Number(data.lat),
				longitude: Number(data.lon),
				address: '',
				name: data.address,
				scale: 18
			})
		},
		async pay(id, type,card) {
			if (type == 1) {
				type = 2 //店铺洗车卡的时候传2
			}
			if(card == 'card'){
				type = 1
			}
			// console.log(id, 'payId')
			let res = await createOrder({
				id,
				type
			})
			// return false;
			if(!res.data.wxpay){
				return false;
			}
			let data = {
				id:res.data.id,
				type,
				score:1
			}
			// uni.navigateTo({
			// 	url: '/components/index/paySuccess?title=支付成功&data=' +JSON.stringify(data)
			// })
			uni.requestPayment({
				"timeStamp": res.data.data.timeStamp,
				"nonceStr": res.data.data.nonceStr,
				"package": res.data.data.package,
				"signType": "MD5",
				"paySign": res.data.data.paySign,
				success: (res) => {
					uni.navigateTo({
						url: '/components/index/paySuccess?title=支付成功&data=' +JSON.stringify(data)
					})
					return true
				}, // 支付成功
				fail: (err) => {
					// return false
				}, // 支付失败
			})
		}
	}
}